<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Sistema de Cadastro</title>
        <link rel="stylesheet" href="menu.css" type="text/css" />
    </h:head>
    <h:body>
        <ui:composition template="template.xhtml">
            <ui:define name="titulo">Sistema de Cadastro</ui:define>

            <ui:define name="body">
                <p:growl id="growl" showDetail="true" life="3000" />
                <h:form prependId="false" id="participantelist">

                    <p:dataTable  var="item" value="#{pessoaController.todos}" style="width:870px; height: 380px" paginator="true" rows="6" >
                        <f:facet name="header">
                            Participantes
                            <p:commandButton update="displayad" oncomplete="participanteAd.show()"
                                             title="Adicionar"          image="ui-icon ui-icon-plusthick"

                                             />

                        </f:facet>
                        <p:column  filterBy="#{item.nome}">
                            <f:facet name="header">
                                <h:outputText value="Nome" />
                            </f:facet>
                            <h:outputText value="#{item.nome}" />
                        </p:column>
                        <p:column  >
                            <f:facet name="header">
                                <h:outputText value="Email" />
                            </f:facet>
                            <h:outputText value="#{item.email}" />
                        </p:column>
                        <p:column  filterBy="#{item.faculdade}">
                            <f:facet name="header">
                                <h:outputText value="Faculdade" />
                            </f:facet>
                            <h:outputText value="#{item.faculdade}" />
                        </p:column>
                        <p:column  filterBy="#{item.evento}">
                            <f:facet name="header">
                                <h:outputText value="Evento" />
                            </f:facet>
                            <h:outputText value="#{item.evento}" />
                        </p:column>


                        <p:column style="width:32px">

                            <p:commandButton update="display3" oncomplete="participanteEx.show()"
                                             title="Excluir"          image="ui-icon ui-icon-trash"

                                             >
                                <f:setPropertyActionListener value="#{item}"
                                                             target="#{pessoaController.bean}" />
                            </p:commandButton>
                            <p:commandButton update="displayed" oncomplete="participanteEd.show()"
                                             title="Editar"          image="ui-icon ui-icon-pencil"

                                             >
                                <f:setPropertyActionListener value="#{item}"
                                                             target="#{pessoaController.bean}" />
                            </p:commandButton>



                        </p:column>

                    </p:dataTable>




                </h:form>

                <h:form prependId="false">


                    <p:dialog header="Excluir Participante" widgetVar="participanteEx" resizable="false"
                              height="170" width="350" showEffect="explode" hideEffect="explode" >

                        <h:panelGrid id="display3" columns="2" cellpadding="4">

                            <h:outputText value="Deseja Excluir ?" />
                            <h:outputText value="#{pessoaController.bean.nome}" />
                            <p:commandButton actionListener="#{pessoaController.excluir}" oncomplete="participanteEx.hide()"
                                             value="ok" image="ui-icon ui-icon-trash" update="participantelist"             />

                        </h:panelGrid>
                    </p:dialog>
                </h:form>

                <h:form prependId="false">
                    <p:dialog  header="Cadastro de Participantes" width="600"
                               widgetVar="participanteAd" resizable="false"
                               showEffect="explode" hideEffect="explode"

                               >
                        <h:panelGrid id="displayad" columns="2" cellpadding="6">

                            <h:outputLabel value="Nome:    "  >
                            </h:outputLabel>
                            <p:inputText value="#{pessoaController.bean.nome}"
                                         required="true"  requiredMessage=" campo nome  obrigatório"/>


                            <h:outputLabel value="Email:    "  >
                            </h:outputLabel>
                            <p:inputText value="#{pessoaController.bean.email}"
                                         required="true"  requiredMessage=" campo email obrigatório"/>

                            <h:outputLabel value="Instiuição:    " id="faculdade" />

                            <h:selectOneMenu converter="faculdade" id="tipofaculdade" styleClass="selecao"
                                             value="#{pessoaController.bean.faculdade}">

                                <f:selectItems
                                    value="#{faculdadeController.combo}" />
                            </h:selectOneMenu>
                            <h:outputLabel value="Evento:    " id="evento" />
                            <h:selectOneMenu id="tipoevento" converter="evento"
                                             value="#{pessoaController.bean.evento}">
                                <f:selectItems
                                    value="#{eventoController.todos}" var="item"  itemLabel="#{item.nome}"
                                    itemValue="#{item}"/>
                            </h:selectOneMenu>
                            <h:outputLabel value="Presente:    "  />
                            <h:selectBooleanCheckbox value="#{pessoaController.bean.presente}" />
                            <p:commandButton actionListener="#{pessoaController.salvar}" oncomplete="participanteAd.hide()"
                                             value="Salvar" image="ui-icon ui-icon-plus" update="growl,participantelist"             />

                        </h:panelGrid>

                    </p:dialog>





                </h:form>


                <h:form prependId="false">

                    <p:dialog  header="Editar Participante" width="600"
                               widgetVar="participanteEd" resizable="false"
                               showEffect="explode" hideEffect="explode"

                               >
                        <h:panelGrid id="displayed" columns="2" cellpadding="6">
                            <h:outputLabel value="Nome:    "  >
                            </h:outputLabel>
                            <p:inputText value="#{pessoaController.bean.nome}"
                                         required="true"  requiredMessage=" campo nome obrigatório"/>


                            <h:outputLabel value="Email:    "  >
                            </h:outputLabel>
                            <p:inputText value="#{pessoaController.bean.email}"
                                         required="true"  requiredMessage=" campo e-mail obrigatório"/>

                            <h:outputLabel value="Instiuição:    "  />

                            <h:selectOneMenu converter="faculdade"  styleClass="selecao"
                                             value="#{pessoaController.bean.faculdade}">

                                <f:selectItems
                                    value="#{faculdadeController.combo}" />
                            </h:selectOneMenu>
                            <h:outputLabel value="Evento:    "  />
                            <h:selectOneMenu  converter="evento"
                                              value="#{pessoaController.bean.evento}">
                                <f:selectItems
                                    value="#{eventoController.todos}" var="item"  itemLabel="#{item.nome}"
                                    itemValue="#{item}"/>
                            </h:selectOneMenu>

                            <h:outputLabel value="Presente:    "  />
                            <h:selectBooleanCheckbox value="#{pessoaController.bean.presente}" />

                            <p:commandButton actionListener="#{pessoaController.update}" oncomplete="participanteEd.hide()"
                                             value="Salvar" image="ui-icon ui-icon-plus" update="growl,participantelist"             />

                        </h:panelGrid>
                        <p:messages/>
                    </p:dialog>
                </h:form>
            </ui:define>
        </ui:composition>






    </h:body>
</html>

